package com.foreknow.service.impl;

import com.foreknow.entity.Rule;
import com.foreknow.mapper.RuleMapper;
import com.foreknow.service.RuleService;
import com.github.pagehelper.PageHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
public class RuleServiceImpl implements RuleService {

    @Autowired
    private RuleMapper ruleMapper;

    /**
     * 查询排班规则
     * @param deptCategoryId
     * @param deptId
     * @param registLeId
     * @param pageNum
     * @param pageSize
     * @return
     */
    @Override
    public List<Rule> getRule(Integer deptCategoryId, Integer deptId, Integer registLeId, Integer pageNum, Integer pageSize) {
        PageHelper.startPage(pageNum, pageSize);
        List<Rule> list = ruleMapper.getRule(deptCategoryId,deptId,registLeId);
        return list;
    }

    /**
     * 新增排班规则
     * @param list
     * @return
     */
    @Override
    public int addRule(List<Rule> list) {
        return ruleMapper.addRule(list);
    }

    /**
     * 修改排班规则
     * @param ruleName
     * @param deptID
     * @param userID
     * @param week
     * @param id
     * @return
     */
    @Override
    public int updateRule(String ruleName,Integer deptID,Integer userID,String week,Integer id) {
        return ruleMapper.updateRule(ruleName,deptID,userID,week,id);
    }

    /**
     * 删除排班规则
     * @param ruleId
     * @return
     */
    @Override
    public int deleteRule(Integer ruleId) {
        return ruleMapper.deleteRule(ruleId);
    }
}